package kr.pe.johnkim.carrotpoint.mobile.controller;

import kr.pe.johnkim.carrotpoint.mobile.service.HelloWorldService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author : johnkim <cale9797@gmail.com>
 * @date: 13. 1. 31.
 */
@Controller
public class HelloWorldController {

    // SLF4J Logging
    private Logger logger = LoggerFactory.getLogger(HelloWorldController.class);

    @Autowired
    HelloWorldService helloWorldService;

    /**
     * 테스트용 GET 메소드이다.
     * @param name
     * @return
     */
    @RequestMapping(value = "/business/{name}", method = RequestMethod.GET)
    @ResponseBody
    public ModelAndView getHelloWorld(String name) {
        logger.info("getHelloWorld");
        logger.info("", helloWorldService.getHello(name).toString());

        ModelAndView mov = new ModelAndView("helloworld");
        mov.addObject("helloworld",helloWorldService.getHello(name)	);

        return mov ;
    }
}
